package com.atguigui.leetcode1;

/**
 * 2367.算术三元组的数目
 * Project: leetcode
 * Package: com.atguigui.leetcode1
 * Version: 1.0
 * <p>
 * Created by WJX on 2023/3/31 8:38
 */
public class P2367NumberOfArithmeticTriplets {
    public static void main(String[] args) {
        Solution solution = new P2367NumberOfArithmeticTriplets().new Solution();
        // TO TEST
    }

    class Solution {
        public int arithmeticTriplets(int[] nums, int diff) {
            int ans = 0;
            int n = nums.length;
            for (int i = 0; i < n; i++) {
                for (int j = i + 1; j < n; j++) {
                    if (nums[j] - nums[i] != diff) {
                        continue;
                    }
                    for (int k = j + 1; k < n; k++) {
                        if (nums[k] - nums[j] == diff && nums[j] - nums[i] == diff) {
                            ans++;
                        }
                    }
                }
            }
            return ans;
        }
    }
}
